#!/bin/bash

# refer to https://gitee.com/api/v5/oauth_doc#/list-item-2
token_file=~/.gitee_token.json
if [ -e $token_file ]; then
    chmod 600 $token_file
fi
echo "Refreshing ~/.gitee_token.json"
curl -s -X POST --data-urlencode "grant_type=password" --data-urlencode "username=hht8" --data-urlencode "password=971222hht@" --data-urlencode "client_id=916884e74e045cea2680a16f407aa032a4380f639f7dc5c28db06f092d06f423" --data-urlencode "client_secret=f4500899fe1efbb8c7ed4514b26a77ce79903b3982f5f1f950c20e3734f03f16" --data-urlencode "scope=projects pull_requests issues" https://gitee.com/oauth/token > $token_file
chmod 400 $token_file
